@extends('layouts.admin')
@section('content')
    <div id="content-header">
        <h1>相片管理</h1>
        <div class="btn-group">
            <a class="btn btn-large tip-bottom" title="Manage Files"><i class="icon-file"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Comments"><i class="icon-comment"></i><span class="label label-important">5</span></a>
            <a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
        </div>
    </div>
    <div id="breadcrumb">
        <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>相片列表</a>
        <a href="#" class="current">相片详情</a>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title">
								<span class="icon">
									<i class="icon-th"></i>
								</span>
                    </div>
                    <div class="widget-content">

                        <div class="container-fluid">
                            <div class="row-fluid">
                                <div class="span12">
                                    <div class="widget-box">
                                        <div class="widget-title">
								<span class="icon">
									<i class="icon-align-justify"></i>
								</span>
                                            <h5>轮播图</h5>
                                        </div>
                                        <div id="err" style="color:red"></div>
                                <div class="widget-content">
								<table class="table table-bordered table-striped with-check">
									<thead>
										<tr>
											<th>排序</th>
											<th>ID</th>
											<th>相册名称</th>
											<th>相片名称</th>
                                            <th>图片</th>
											<th>相片描述</th>
											<th>增添时间</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
									@foreach($banner as $u)
										<tr>
											<td style="line-height:50px;vertical-align:middle"><input type="text" name="ord[]" value="{{$u->order}}" style="width:40px;text-align:center;line-height:50px;margin-bottom:0px" onchange="changeOrder(this,{{$u->id}})"></td>
											<td style="text-align:center;line-height:50px;vertical-align:middle"class="idds">{{$u->id}}</td>
											<td style="text-align:center;line-height:50px;vertical-align:middle"class="idds">{{$u->album_name}}</td>
											<td style="text-align:center;line-height:50px;vertical-align:middle" class="names">{{$u->name}}</td>
											<td style="text-align:center;line-height:50px;vertical-align:middle"><img src="{{$u->path}}" alt="" width="100px"></td>
											<td style="text-align:center;line-height:50px;vertical-align:middle">{{$u->describe}}</td>
											<td style="text-align:center;line-height:50px;vertical-align:middle">{{date("Y-m-d H:m:s",$u->ctime)}}</td>
											<td style="text-align:center;line-height:50px;vertical-align:middle"><button type="button" class="btn btn-success"><a href="{{url('admin/banner/'.$u->id. '/edit')}}" style="color:white">修改</a></button> |
                                                <button type="button" class="btn btn-success"><a href="javascript:" onclick="delArt({{$u->id}})" style="color:white">删除</a></button>
                                            </td>
										</tr>
										@endforeach
									</tbody>
								</table>
							</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="row-fluid">
                <div id="footer" class="span12">
                    2012 &copy; Unicorn Admin. Brought to you by <a href="https://wrapbootstrap.com/user/diablo9983">diablo9983</a>
                </div>
            </div>
        </div>
	<script type="text/javascript">
            $('#form1').hide();
                function changeOrder(obj,id){
                    var order = $(obj).val();
                    $.post("{{url('admin/banner/changeOrder')}}",{'_token':'{{csrf_token()}}','id':id,'order':order},function(data){
                       console.log(data);
                        if(data.status==0){
                            layer.alert(data.msg, {icon: 6});
                        }else{
                            layer.msg(data.msg, {icon: 5});
                        }
                    });
                }
                // 删除友情导航
                function delArt(id){
                    layer.confirm('您确定要删除？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        $.post("{{url('admin/banner')}}/"+id,{'_method':'delete','_token':'{{csrf_token()}}'},function(data){
                            console.log(data);
                            if(data.status==0){
                                location.href=location.href;
                                layer.msg(data.msg,{icon:6});
                            }else{
                                layer.msg(data.msg,{icon:5});
                            }
                        });
                    }, function(){

                    });
                }
    </script>
    </div>
@endsection